﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ProjectCore.Application.AppOrder;
using ProjectCore.Domain.Model.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ProjectCore.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OrderController : ControllerBase
    {
        private readonly IAppOrder appOrder;
        public OrderController(IAppOrder _appAdmin)
        {
            appOrder = _appAdmin;
        }
        /// <summary>
        /// 获取订单表集合
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetOrders()
        {
            List<Order> orders = await appOrder.GetOrders();
            return Ok(new { data = orders });
        }
        /// <summary>
        /// 获取订单数据
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetOrder(int Id)
        {
            Order order =await appOrder.GetOrder(Id);
            return Ok(new { data = order });
        }
        /// <summary>
        /// 批量发货
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> UptState(string Id)
        {
            int n =await appOrder.UptState(Id);
            return Ok(new { data = n });
        }
        /// <summary>
        /// 获取地址数据
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPost]
        public  async Task<ActionResult> GetStie(int Id)
        {
            Site site = await appOrder.GetSite(Id);
            return Ok(new
            {
                data = site
            });
        }
        /// <summary>
        /// 获取支付数据
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPost]
        public  async Task<ActionResult> GetPay(int Id)
        {
            Pay pay = await appOrder.GetPay(Id);
            return Ok(new
            {
                data = pay
            });
        }
    }
}
